package com.kh.statistics.video.factory;

import com.kh.statistics.video.core.Platform;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName DefaultPlatformFactory
 * @Description TODO
 * @Author konghong1
 * @Date 2024/5/7 22:06
 * @Version 1.0
 **/
@Component
public class DefaultPlatformFactory implements PlatformFactory {
    private Map<String, Platform> map = new HashMap();

    @Autowired
    public void loadingPlatform(List<Platform> platformList) {
        platformList.forEach((item) -> {
            map.putIfAbsent(item.support(), item);
        });
    }

    @Override
    public Platform getPlatform(String type) {
        return map.get(type);
    }
}
